package com.zx.Servlet;

import com.google.gson.Gson;
import com.zx.Moudel.Queue;
import com.zx.Service.UserService;
import com.zx.Service.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * com.zx.Servlet
 * 26832
 * zx
 * &#064;description:
 * &#064;author: lxm
 * ST
 * &#064;create: 2024-06-22 21:38
 **/
@WebServlet("/St")
public class ST extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        String idcard1 = req.getParameter("idcard");
        String vaccine1 = req.getParameter("vaccine");
        System.out.println("selectQueue:"+idcard1+" "+vaccine1);
        Queue queue = new Queue();
        UserService userService = new UserServiceImpl();
        List<Queue> list = new ArrayList<>();
        list = userService.selectAllQueue(idcard1, vaccine1);
        String json = "";
        Gson gson = new Gson();
        json = gson.toJson(list.get(0));
        resp.getWriter().write(json);//把数据包装为json格式返回给前端页面
    }
}
